package com.test.controller;

import com.test.domain.Dish;
import com.test.enums.Page;
import com.test.enums.Replay;
import com.test.service.DishService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * DishController
 *
 * @author HY
 * 2021/05/24 9:08
 **/

@Api(tags = "菜品管理接口")
@RestController
@RequestMapping("/admin/dish")
public class DishController {

    @Resource
    private DishService dishService;

    @PostMapping("/insert")
    @ApiOperation("添加菜品")
    public Replay insert(Dish dish){

        Replay replay = dishService.insert(dish);
        return replay;
    };

    @PostMapping("/del")
    @ApiOperation("删除菜品")
    public Replay del(@RequestBody int id){

        Replay replay = dishService.del(id);
        return replay;
    };

    @PostMapping("/update")
    @ApiOperation("修改菜品信息")
    public Replay update(@RequestBody Dish dish){

        Replay replay = dishService.update(dish);
        return replay;
    };

    @GetMapping("/select")
    @ApiOperation("查询菜品")
    public Replay select(@RequestParam Dish dish,@RequestParam Page page){

        Replay replay = dishService.select(dish, page);
        return replay;
    };

    @GetMapping("/selectById")
    @ApiOperation("通过菜的id查询菜品")
    public Dish selectById( Dish dish){
        Dish dish1 = dishService.selectById(dish);
        System.out.println(dish1);
        return dish1;
    };





}
